package com.mpyy.service.purchase;

import com.mpyy.dao.purchase.UpdatePurchaseDaoInter;
import com.mpyy.pojo.InventoryChange;
import com.mpyy.pojo.InventoryDesc;
import com.mpyy.pojo.PurchaseStock;
import com.mpyy.pojo.PurchaseStockDesc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @version 1.0
 * @Descoription UpdatePurchaseServiceImpl
 * @Author CG
 * @date 2022-03-22
 */
@Service(value = "updatePurchaseServiceImpl")
public class UpdatePurchaseServiceImpl implements UpdatePurchaseServiceInter {
   @Autowired
   @Qualifier(value = "updatePurchaseDaoInter")
    private UpdatePurchaseDaoInter purchaseDaoInter;
    @Override
    @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.READ_COMMITTED)
    public int updatePurchaseInfo(PurchaseStock purchaseStock,
                                  List<PurchaseStockDesc> purchaseStockDescList,
                                  List<InventoryDesc> inventoryDescList,
                                  List<InventoryChange> changeList) {

        for (InventoryDesc desc : inventoryDescList) {
            System.out.println(desc);
        }
        //调用dao层新增采购订单的方法
        int i = purchaseDaoInter.updatePurchaseStock(purchaseStock);
        //调用dao层新增采购订单详情的方法
        int s = purchaseDaoInter.updatePurStockDesc(purchaseStockDescList);
        //调用dao层新增仓库详情信息的方法
        int row = purchaseDaoInter.updateInventoryDesc(inventoryDescList);
        for (InventoryChange inventoryChange : changeList) {
            System.out.println(inventoryChange);
        }
        int rows= purchaseDaoInter.updateInventoryChange(changeList);


        return rows;
    }
}
